package com.ruoyi.web.controller.comprehensive;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.comprehensive.domain.DustPreventionExamine;
import com.ruoyi.comprehensive.dto.DustPreventionExamineDto;
import com.ruoyi.comprehensive.service.IDustPreventionExamineService;
import com.ruoyi.comprehensive.vo.DustVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 防尘审核Controller
 *
 * @author hcc
 * @date 2023-12-15
 */
@RestController
@RequestMapping("/comprehensive/dustExamine")
public class DustPreventionExamineController extends BaseController
{
    @Autowired
    private IDustPreventionExamineService dustPreventionExamineService;

    /**
     * 查询防尘审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:list')")
    @GetMapping("/list")
    public TableDataInfo list(DustPreventionExamine dustPreventionExamine)
    {
        startPage();
        List<DustPreventionExamine> list = dustPreventionExamineService.selectDustPreventionExamineList(dustPreventionExamine);
        return getDataTable(list);
    }

    /**
     * 导出防尘审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:export')")
    @Log(title = "防尘审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DustPreventionExamine dustPreventionExamine)
    {
        List<DustPreventionExamine> list = dustPreventionExamineService.selectDustPreventionExamineList(dustPreventionExamine);
        ExcelUtil<DustPreventionExamine> util = new ExcelUtil<DustPreventionExamine>(DustPreventionExamine.class);
        util.exportExcel(response, list, "防尘审核数据");
    }

    /**
     * 获取防尘审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(dustPreventionExamineService.selectDustPreventionExamineById(id));
    }

    /**
     * 新增防尘审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:add')")
    @Log(title = "防尘审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DustPreventionExamine dustPreventionExamine)
    {
        return toAjax(dustPreventionExamineService.insertDustPreventionExamine(dustPreventionExamine));
    }

    /**
     * 修改防尘审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:edit')")
    @Log(title = "防尘审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DustPreventionExamine dustPreventionExamine)
    {
        return toAjax(dustPreventionExamineService.updateDustPreventionExamine(dustPreventionExamine));
    }

    /**
     * 删除防尘审核
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:remove')")
    @Log(title = "防尘审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dustPreventionExamineService.deleteDustPreventionExamineByIds(ids));
    }
    /**
     * 查询防尘审核列表
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:list')")
    @GetMapping("/getList")
    public TableDataInfo getList(DustVo vo) {
        startPage();
        PageInfo<DustPreventionExamineDto> list = dustPreventionExamineService.getDustPreventionExamineList(vo);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setMsg("查询成功");
        rspData.setRows(list.getList());
        rspData.setTotal(list.getTotal());
        return rspData;
    }

    /**
     * 获取防尘审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('comprehensive:dustExamine:query')")
    @GetMapping("/getDustPreventionExamineById/{id}")
    public AjaxResult getDustPreventionExamineById(@PathVariable("id") String id) {
        DustPreventionExamineDto dustPreventionExamineDto = dustPreventionExamineService.getDustPreventionExamineById(id);
        return success(dustPreventionExamineDto);
    }
}
